using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;

namespace IQIGame.Onigao.Logic
{
    public partial class LevelPlayer : IConditionPropFetcher
    {
        public int FetchConditionProp(ConditionBlackboard blackboard, int iType, IReadOnlyList<int> curValueParams)
        {
            ConditionCurPlayerPropType type = (ConditionCurPlayerPropType)iType;
            LevelPlayer player = blackboard.curPlayer as LevelPlayer;
            switch (type)
            {
                case ConditionCurPlayerPropType.IsEntityFollowHero:
                    int entityMcid = curValueParams[0];
                    if (entityMcid <= 0) //是否被实体跟随
                    {
                        return entityFollowingMe != null ? 1 : 0;
                    }
                    else //是否被指定实体跟随
                    {
                        return entityFollowingMe != null && entityFollowingMe.entityConfig.id == entityMcid ? 1 : 0;
                    }
                case ConditionCurPlayerPropType.IsQuestInProgress:
                    int questCid1 = curValueParams[0];
                    bool v1 = player.logicPlayer.currentQuests.ContainsKey(questCid1);
                    return v1 ? 1 : 0;
                case ConditionCurPlayerPropType.IsQuestFinished:
                    int questCid2 = curValueParams[0];
                    bool v2 = player.logicPlayer.committedQuests.ContainsKey(questCid2);
                    return v2 ? 1 : 0;
                case ConditionCurPlayerPropType.HaveBuff:
                    int buffCid = curValueParams[0];
                    return buffManager.ContainsBuff(buffCid) ? 1 : 0;
                default:
                    LogicLog.LogError($"关卡逻辑层不支持的条件类型：2 - {iType}");
                    return 0;
            }
        }
    }
}
